import logging.handlers

import config.path_cfg as cfg

def init_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    fh = logging.handlers.TimedRotatingFileHandler(cfg.BASE_DIR + '/log/iHRM_log.log',
                                                   when='midnight',
                                                   interval=1,
                                                   backupCount=2,
                                                   encoding='utf-8')

    fmt = "%(asctime)s %(levelname)s [%(filename)s(%(funcName)s:%(lineno)d)] - %(message)s"

    formatter = logging.Formatter(fmt)
    fh.setFormatter(formatter)
    logger.addHandler(fh)
